< previous page page_143 next page >

Page 143
8694cbadb9b1ef7075903f6f95fc1db2.gif
 6:         MsgBox Please enter a valid age limit, vbCritical, App.Title
 7:         Exit Sub
 8:     ElseIf Not IsDate(mskDate) Then
 9:         MsgBox An invalid date was entered., vbCritical, App.Title
10:         Exit Sub
11:     End If
12:     NewAge.AgeLimit = CInt(txtAgeLimit.Text)
13:     NewAge.Birthdate = mskDate.Text
14:     NewAge.CalcAge
15: End Sub
16:
17: Private Sub newage_underage()
18:     MsgBox This person is under the age limit of:  & NewAge.AgeLimit & _  with an age of:  & NewAge.Age
19:
20: End Sub
21:
22: Private Sub newage_overage()
23:     MsgBox This person is over the age limit of:  & NewAge.AgeLimit & _  with an age of:  & NewAge.Age
24:
25: End Sub

Start the application, enter an age limit for the application to use, then enter a date and click the command button. If the date is less than the age limit you entered you will get the message shown in Figure 5.12.
Of course, in more sophisticated class modules, these methods and events would perform
12181-0143a.gif
Figure 5.12.
For each event of the
GetAge class, a
different message box will
be displayed.
much more complicated processes than what is shown in this example. The neat thing about this whole topic is that after the class is created and saved, you can add it to any other application project in which you must use it.
Browsing Your Objects..
When working with classes that you have created, or with any class that comes with Visual Basic, you can view all of their associated properties, methods, and events by using the Object Browser. The Object Browser tool comes with Visual Basic and gives you one single location to look for objects and object information. When you first open the Object Browser from the View, Object Browser menu option, the default browser dialog box will be displayed as shown in Figure 5.13.
The Object Browser displays information contained in type libraries. A type library

 
< previous page page_143 next page >

If you like this book, buy it!